// vite.config.js
import { defineConfig } from 'vite'
import viteBaseConfig from './env/vite.base.config';
import viteDevConfig from './env/vite.dev.config';
import viteProdConfig from './env/vite.prod.config';
import viteBuildConfig from './env/vite.build.config';

const envResolver = {
    "build":() =>{
        console.log('打包开始')
        // return Object.assign({},viteBaseConfig,viteBuildConfig)
    },
    "serve":() => {
        console.log('开发环境启动')
        return Object.assign({},viteBaseConfig,viteDevConfig)
    },
    "prod":() => {
        console.log('静态环境启动')
        return Object.assign({},viteBaseConfig,viteProdConfig)
    }
}

export default defineConfig(({command,mode})=>{
    // console.log('command',command)
    console.log('mode',mode)
    if(mode==='prod'){
        return envResolver.prod();
    }else{
        return envResolver[command]();
    }
    // console.log('process',process.env)
    // return envResolver[command]();
})
